/**
 * 添加流程部署addDeployment.js
 * 版本号： v1.0.0
 */
$(function () {

    //添加流程部署
    $("#addDeployment").bind("click", function(){
        doAddDeployment();
    })




});


function doAddDeployment() {
    if($("#addDeployment").linkbutton('options').disabled == false){
        var fileName = $("#fileName").textbox('getValue');
        if("" == fileName){
            $.messager.show({ title:'提示', msg: '流程名称不能为空！', timeout:3000, showType:"slide" });
            return;
        }
        var file = $("#file").filebox('getValue');
        if("" == file){
            $.messager.show({ title:'提示', msg: '请选择要上传附件！', timeout:3000, showType:"slide" });
            return;
        }
        //获取上传文件名称
        var getfileName = file.substring(file.lastIndexOf("\\") + 1);
        //获取文件后缀
        var suffix = getfileName.substring(getfileName.lastIndexOf(".") + 1).toUpperCase();
        if("zip" != suffix && "ZIP" != suffix){
            $.messager.show({ title:'提示', msg: '上传文件格式有误！', timeout:3000, showType:"slide" });
            return;
        }
        var dataType= "json";
        if(isIE()){
            dataType = "text/html";
        }else{
            dataType = "json";
        }
        $("#deployment_form").ajaxSubmit({
            url: CONTEXT_PATH + "/deployment/addDeployment.do",
            dataType: dataType,
            type: "post",
            clearForm: false,
            beforeSubmit : function() {
                $.messager.progress({
                    title: "提示",
                    msg: "流程部署中, 请稍候...",
                    text: ''
                });
            },
            complete : function(){
                $.messager.progress('close');
            },
            success : function(data, statusText) {
                //解决IE下载问题
                if(isIE()){
                    data = toJson(data);
                }
                //消息提示
                messager(data);
                //赋值元素
                if("PC_200" == data.code){
                    setTimeout(function() { window.location.href = CONTEXT_PATH + "/deployment/index.do"; }, "3000");
                }
            },
            error : function(xhr, status, err) {
                $.messager.show({ title:'提示', msg: '附件上传失败！', timeout:3000, showType:"slide" });
            }
        });


    }
}







